<?php

interface ArticleDao {
	public function getArticles($sectionId, $isHome);
}

class ArticleDaoImpl implements ArticleDao {
	public function getArticles($sectionId, $isHome) {
                if (!mysql_connect("localhost", "root", "password") || !mysql_select_db("nettuts")) {
                        throw new Exception(mysql_error());
                }

                $q = "
                SELECT
                        a.id,
                        a.title
                FROM    features f
                LEFT JOIN article a ON f.article_id = a.id AND f.section_id = $sectionId
                ";

                $resource = mysql_query($q);

                if ($resource === false) {
                        throw new Exception(mysql_error());
                }


                $articles = array();
                while($row = mysql_fetch_array($resource))  {
                        $article = array();
                        $article['id'] = $row['id'];
                        $article['title'] = $row['title'];

                        $articles[] = $article;
                }

                return $articles;
        }
	
} 
